/*============================
*	File Name: Cat.c
*	Created Date: 12/17/2021 11:16:56 AM
*	Last Modified Date:12/17/2021 11:45:19 AM
*	Author: mistgc
*	Email: georgecai0908@outlook.com
============================*/
#include "Cat.h"
#include <stdio.h>
#include <stdlib.h>

static void Cat_eat_(Pet const * const me);

void Cat_ctor(Cat * const me, char *name, int color){
	static PetVTBL vtbl = {
		&Cat_eat_
	};
	Pet_ctor(&me->super, name);
	me->super.vptr = &vtbl;				//重载vptr
	me->color = color;
}

char *Cat_getColor(Cat const * const me){
	char *temp = (char *)malloc(sizeof(char) * 5);
	switch(me->color){
		case 1:
			temp = "White";
			break;
		case 2:
			temp = "Black";
			break;
	}
	return temp;
}

static void Cat_eat_(Pet const * const me){
	char *color = Cat_getColor((Cat const * const)me);
	printf("%s cat ,%s is eating...\n", color,Pet_getName(me));
	free(color);					//If not, it will be memory leaks.
}
